<?php
/**
 * E (Exception) Klasse
 * 
 * Abstrakte Klasse für Exceptions
 * 
 * $Rev: $
 * $Author: $
 * $Date: $
 * $Id: $
 * $URL: $
 * @author Adrian Liechti <info@jahweh.ch>
 * @copyright: 2010-2011 Adrian Liechti, GPL3 and CC3 BY-SA
 */

abstract class e extends Exception implements eInterface {
	protected	$message	= 'Unknown exception';
	protected	$code		= 0;
	protected	$file;
	protected	$line;

	public function __construct($message = null, $code = 0) {
		if (!$message) {
			throw new $this('Unknown '.$this->type().' in File "'.$this->file.'" on Line "'.$this->line.'"');
		}
		parent::__construct($message, $code);
		log::addException($exception);
	}
	 
	public function __toString() {
		return get_class($this)." '{$this->message}' in {$this->file()}({$this->line})\n"."{$this->getTraceAsString()}";
	}
	
	public function addVar ($title, $value) {
		$this->vars[] = array('t'=>$title, 'v'=>$value);
	}
	
	public function file () {
		global $pluginLoader;
		var_dump($pluginLoader->dirRoot,$this->file);
		return str_replace($pluginLoader->dirRoot, '', $this->file);
	}
	
	public function type () {
		return get_class($this);
	}
}
?>